/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.rh.game.impl;

import com.rh.game.Character;
import com.rh.game.GameObject;
import com.rh.game.GameClothing;
import com.rh.game.Location;
import com.rh.game.MagicalEffect;

import com.rh.game.chat.ChatImage;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Hayden
 */
public class Character1 extends GameObject1 implements Character {
    private byte initialGridID = 0;
    private byte gridID = 0;
    public byte getGridID() { 
        return gridID; 
    }
    
    private List<GameObject> inventory = new ArrayList<GameObject>();
    public List<GameObject> getInventory()  { return inventory; }
    public void addInventory(GameObject go)  {
        if (go == null)  return;
        inventory.add(go);
    }
    public void removeInventory(GameObject go)  {
        if (go == null)  return;
        inventory.remove(go);
    }
    private List<GameClothing> wearing = new ArrayList<GameClothing>();
    public List<GameClothing> getWearing()  { return wearing; }

    public Character1(String pID, String pName, Location pLoc, Gender pGender, ChatImage pImage, byte pGridID)  {
        super(pID, pName, pLoc, MagicalEffect.EMPTY_LIST);
        setGender(pGender);
        image = pImage;
        gridID = pGridID;
        initialGridID = pGridID;
    }

    private List<ShowImage> specialImages = new ArrayList<ShowImage>();
    public void addSpecialImage(String pImage, List<String> pConditions)  {
        ShowImage si = new ShowImage(this, pConditions, pImage);
        specialImages.add(si);
    }
    private ChatImage image = ChatImage.NULL;
    
    @Override
    public ChatImage getImage()  { 
        ChatImage ci = image;
        for (ShowImage si : specialImages)  {
            if (si.useImage())  {
                ci = new ChatImage(si.getImage());
                break;
            }
        }
        return ci; 
    }

    private Gender gender = Gender.FEMALE;
    public Gender getGender() {
        return gender;
    }

    public void setGender(Gender gender) {
        this.gender = gender;
        if (initialGridID == 8)  {
            gridID = 8;
            if (gender == Gender.FEMALE)  gridID = 9;
        }
        else if (initialGridID == 10)  {
            gridID = 10;
            if (gender == Gender.FEMALE)  gridID = 11;
        }
    }
}
